	<script type="text/javascript">                                         
	var shownodes_setting = "";
	var showtasks_setting = "";
	$(document).ready(function() {
		
		$("#tasksTable").tablesorter();
		$("#nodesTable").tablesorter();
		
		//$("#canyouseeme").addClass("blue");
		//$("#canyouseeme", top.document).append("YES!"); 
		//$("#hideme").append("something");
		//$("#hideme").click(function(e){
		//	e.preventDefault();
		//	$("#submit_iframe", top.document).fadeOut("slow");
		//});
		
		updateSettings()
		updatetasklist();
			
		
		$(function() {
			$tabs = $("#monitor_tabs").tabs();
		});

		
		$("#updatetasklist").click(function(e){
			e.preventDefault();
			updateSettings();
			updatetasklist();
		});

		$("#updatenodelist").click(function(e){
			e.preventDefault();
			updateSettings()
			updatenodelist("");
		});

	});
	function set_last_task_monitor(loc_last_task){
		last_task = loc_last_task;
		// update the monitor list
		updatetasklist();
		// switch monitor tab , task list
		//$("#tabs").tabs('select', 0);
		//$("#monitor_tabs").tabs('select', 0);
	}
	function parseMyDate(datestring){
		var date = datestring;
		date = date.replace(/-/g, ":");
		date = date.replace(/ /g, ":");
		var date_array = date.split(":");
		var newDate = new Date(date_array[0],parseInt(date_array[1])-1,date_array[2],date_array[3],date_array[4],date_array[5]);
		return newDate;
	}	
	
	function updateSettings(){
		$.get("settingUpdate", function(data){
			//var accordion_string = data;
			
			var JSONobj = eval(data);
			jQuery.each(JSONobj, function(i, val) {
				if (val.name == "shownodes"){
					shownodes_setting = val.value;
				} else if (val.name == "showtasks"){
					showtasks_setting = val.value;
				}
			});
		});
	}
	function updatetasklist(){
		$("#tasksTableBody").html('<tr><td colspan="8">Please wait while the Tasks List is loading...</td></tr>');
		$.get("taskUpdate", function(data){
			//var accordion_string = data;
			
			var JSONobj = eval(data);
			var tasklist_content_panel_string = "";
			//alert(+showtasks_setting);
			
			jQuery.each(JSONobj, function(i, val) {
				var lastActive = parseMyDate(val.start_time);
				var showAfter = new Date();
				var tdTagStyle;
				showAfter.setHours(showAfter.getHours()-parseInt(showtasks_setting));
				
				if (lastActive.getTime() > showAfter.getTime()){
					if (val.id != last_task){
						tdTagStyle = '';
					} else {
						tdTagStyle = 'style="background-color:#E17009;"';
					}
					tasklist_content_panel_string += 	'<tr onclick="set_last_task_monitor(\''+val.id+'\');">'+
															'<td '+tdTagStyle+'>'+val.name+'</td>'+
															'<td '+tdTagStyle+'><div id="tasklist_progressbar'+i+'"></div></td>'+
															'<td '+tdTagStyle+'>'+val.id+'</td>'+
															'<td '+tdTagStyle+'>'+val.start_time+'</td>'+
															'<td '+tdTagStyle+'>'+val.finish_time+'</td>'+
															'<td '+tdTagStyle+'>'+val.nodes+'</td>'+
															'<td '+tdTagStyle+'>'+val.tasks_completed+'</td>'+
															'<td '+tdTagStyle+'>'+val.tasks+'</td>'+
														'</tr>';
				}
			});
			//alert(tasklist_content_panel_string);
			$("#tasksTableBody").html(tasklist_content_panel_string);
			//alert(document.getElementById('tasksTableBody').innerHTML);
			jQuery.each(JSONobj, function(i, val) {
				$(function() {
					$("#tasklist_progressbar"+i).progressbar({
						value: 100*(eval(val.tasks_completed)/eval(val.tasks)) 
					});
				});
			});
			$("#tasksTable").trigger("update");
		});
	}
	function updatenodelist(node_id){
		$("#nodesTableBody").html('<tr><td colspan="5">Please wait while the Node List is loading...</td></tr>');
		$.get("nodeUpdate", function(data){
			var test = parseInt(shownodes_setting) + 7;
			//alert (test);
			var JSONobj = eval(data);
			var nodelist_content_string = "";
			
			jQuery.each(JSONobj, function(i, val) {
				var lastActive = parseMyDate(val.last_update);
				var showAfter = new Date();
				showAfter.setHours(showAfter.getHours()-parseInt(shownodes_setting));
				
				if (lastActive.getTime() > showAfter.getTime()){
					nodelist_content_string += '<tr><td>'+val.id+'</td><td>'+val.start_time+'</td><td>'+val.last_update+'</td><td>'+val.jobs+'</td><td>'+val.status+'</td></tr>';
				 }
			});
			$("#nodesTableBody").html(nodelist_content_string);
			// make table sortable
			$("#nodesTable").trigger("update"); 
		});
	}

	</script>
			<div id="monitor_tabs">
				<ul>
					<li><a id="updatetasklist" href="#monitor_tabs-1">Task List</a></li>
					<li><a id="updatenodelist" href="#monitor_tabs-2">Node List</a></li>
				</ul>
				<div id="monitor_tabs-1">
					<div id="tasklist">
						<table id="tasksTable" class="tablesorter"> 
							<thead> 
								<tr> 
									<th>Name</th> 
									<th>Progress</th> 
									<th>Task ID</th> 
									<th>Start Time</th> 
									<th>Finish Time</th> 
									<th>Nodes Used</th> 
									<th>Frames Completed</th> 
									<th>Total # Frames</th>
								</tr> 
							</thead> 
							<tbody id="tasksTableBody"> 
							
							</tbody>
						</table>
					</div>                                                                  
				</div>
				<div id="monitor_tabs-2">
					<div id="nodelist">
						<table id="nodesTable" class="tablesorter"> 
							<thead> 
								<tr> 
									<th>Node ID</th> 
									<th>Start Time</th> 
									<th>Last Activity</th> 
									<th>Jobs Processed</th> 
									<th>Status</th>
								</tr> 
							</thead> 
							<tbody id="nodesTableBody"> 
							
							</tbody>
						</table>
					</div>                                                                  
				</div>
			</div>
			</div>